//
//  PostNetWorking.m
//  ccpBuild
//
//  Created by chirui on 16/6/15.
//  Copyright © 2016年 chirui. All rights reserved.
//

#import "PostNetWorking.h"
#import "AFNetworking.h"

@implementation PostNetWorking

+(void)netWorkingStr:(NSString *)str  Success:(SuccessBlock)suceess failed:(FailurelBlock)failed {
    
   AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; 
    [manager.requestSerializer willChangeValueForKey:@"timeoutInterval"];
     manager.requestSerializer.timeoutInterval = 8.f;
    [manager.requestSerializer didChangeValueForKey:@"timeoutInterval"];
//      manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html",@"text/plain",nil];// AF框架中已添加
    [manager GET:str parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) {
        
    }
         success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {

      suceess(responseObject);
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull   error){
        
        failed(task,error);
    }];

}


+(void)postNetWorkingStr:(NSString *)str andparameters:(id)paramet  Success:(SuccessBlock)suceess failed:(FailurelBlock)failed {
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
//     manager.requestSerializer = [AFJSONRequestSerializer serializer];
    [manager.requestSerializer willChangeValueForKey:@"timeoutInterval"];
    manager.requestSerializer.timeoutInterval = 8.f;
    [manager.requestSerializer didChangeValueForKey:@"timeoutInterval"];
     manager.responseSerializer.acceptableContentTypes =  [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript",@"text/html", nil]; // AF框架中已添加
    [manager POST:str parameters:paramet progress:^(NSProgress * _Nonnull uploadProgress) {
        
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject)  {
        
        suceess(responseObject);
        
    }failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        
        failed(task,error);
    }];
    
}

@end
